package com.manage.module.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manage.module.entity.Books;
import com.manage.module.mapper.BooksMapper;
import com.manage.module.service.BooksService;
import com.manage.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 图书表 服务实现类
 * </p>
 *
 */
@Slf4j
@Service
public class BooksServiceImpl extends ServiceImpl<BooksMapper, Books> implements BooksService {

    @Override
    public R pageBooks(Page page, Books books) {
        return new R(this.page(page, Wrappers.lambdaQuery(books).eq(Books::getDelFlag,"0")));
    }

    @Override
    public R saveBooks(Books books) {
        this.save(books);
        log.info("新增图书成功");
        return new R(true);
    }

    @Override
    public R updateBooks(Books books) {
        this.updateById(books);
        log.info("更新图书成功");
        return new R(true);
    }

    @Override
    public R deleteBooks(Books books) {
        books.setDelFlag("-1");
        this.updateById(books);
        log.info("删除图书成功");
        return new R(true);
    }
}
